package com.ashlikun.camera.scan.analyze

/**
 * 作者　　: 李坤
 * 创建时间: 2024/6/17　16:35
 * 邮箱　　：496546144@qq.com
 *
 * 功能介绍：可以插入Nv21的过滤
 */
open abstract class AbsNv21Analyzer<T>(data: Nv21Analyzer? = null) : Analyzer<T> {
    protected val dataFilter: MutableList<Nv21Analyzer> = ArrayList()

    init {
        if (data != null) {
            dataFilter.add(data)
        }
    }

    fun addDataFilter(data: Nv21Analyzer) {
        dataFilter.add(data)
    }

    open fun callNv21(nv21Data: ByteArray, width: Int, height: Int): ByteArray {
        var nv21Data = nv21Data
        for (i in dataFilter.indices) {
            nv21Data = dataFilter[i].analyzeNv21(nv21Data, width, height)
        }
        return nv21Data
    }
}